<template>
  <div class="table-container">
    <el-table
      ref="goodsTable"
      :data="goodsList"
      style="width: 100%"
      v-loading="listLoading"
      border
    >
      <el-table-column type="selection" width="60" align="center"></el-table-column>

      <el-table-column label="商品图片" width="200" align="center">
        <template slot-scope="scope">
          <img style="height: 80px" :src="scope.row.imageUrl" :title="scope.row.description"/>
        </template>
      </el-table-column>

      <el-table-column label="商品标题" width="200" align="center">
        <template slot-scope="scope">{{scope.row.title}}</template>
      </el-table-column>

      <el-table-column label="价格" width="80" align="center">
        <template slot-scope="scope">{{scope.row.price}}</template>
      </el-table-column>

      <el-table-column label="数量" width="80" align="center">
        <template slot-scope="scope">{{scope.row.amount}}</template>
      </el-table-column>

      <el-table-column label="商品描述" width="200" align="center">
        <template slot-scope="scope">{{scope.row.description}}</template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getGoodsList } from '@/api/goods';

export default {
  name: "goodsList1",
  data() {
    return {
      goodsList: null,
      listLoading: true,
    };
  },
  created() {
    this.getGoodsList();
  },
  methods: {
    getGoodsList() {
      this.listLoading = true;
      getGoodsList().then((response) => {
        this.listLoading = false;
        this.goodsList = response.data;
        console.log(this.goodsList);
      });
    },
  },
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>
